from django.views.generic import ListView, DetailView, CreateView, \
                                 DeleteView, UpdateView, \
                                 ArchiveIndexView, DateDetailView, \
                                 DayArchiveView, MonthArchiveView, \
                                 TodayArchiveView, WeekArchiveView, \
                                 YearArchiveView


from weather.models import UserOfficial


class UserOfficialView(object):
    model = UserOfficial

    def get_template_names(self):
        """Nest templates within userofficial directory."""
        tpl = super(UserOfficialView, self).get_template_names()[0]
        app = self.model._meta.app_label
        mdl = 'userofficial'
        self.template_name = tpl.replace(app, '{0}/{1}'.format(app, mdl))
        return [self.template_name]


class UserOfficialDateView(UserOfficialView):
    date_field = 'regtime'
    month_format = '%m'


class UserOfficialBaseListView(UserOfficialView):
    paginate_by = 10


class UserOfficialArchiveIndexView(
    UserOfficialDateView, UserOfficialBaseListView, ArchiveIndexView):
    pass


class UserOfficialCreateView(UserOfficialView, CreateView):
    pass


class UserOfficialDateDetailView(UserOfficialDateView, DateDetailView):
    pass


class UserOfficialDayArchiveView(
    UserOfficialDateView, UserOfficialBaseListView, DayArchiveView):
    pass


class UserOfficialDeleteView(UserOfficialView, DeleteView):

    def get_success_url(self):
        from django.core.urlresolvers import reverse
        return reverse('weather_userofficial_list')


class UserOfficialDetailView(UserOfficialView, DetailView):
    pass


class UserOfficialListView(UserOfficialBaseListView, ListView):
    pass


class UserOfficialMonthArchiveView(
    UserOfficialDateView, UserOfficialBaseListView, MonthArchiveView):
    pass


class UserOfficialTodayArchiveView(
    UserOfficialDateView, UserOfficialBaseListView, TodayArchiveView):
    pass


class UserOfficialUpdateView(UserOfficialView, UpdateView):
    pass


class UserOfficialWeekArchiveView(
    UserOfficialDateView, UserOfficialBaseListView, WeekArchiveView):
    pass


class UserOfficialYearArchiveView(
    UserOfficialDateView, UserOfficialBaseListView, YearArchiveView):
    make_object_list = True



